package com.microinvest.controller.stock;

import com.microinvest.entity.Stock;
import com.microinvest.entity.Users;
import com.microinvest.service.StockCountService;
import com.microinvest.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/stock")
public class StockController {

    private final StockCountService stockCountService;

    @Autowired
    public StockController(StockCountService stockCountService){
        this.stockCountService=stockCountService;
    }

    @GetMapping("/getStockMessage")
    public Result<List<String>> getStocksMessage(String stockName) throws Exception {
        Result<List<String>> result= stockCountService.getStockMessage(stockName);
        return result;

    }
    @PostMapping("/createStockData")
    public Result createStock(String StockName,double FirstPrice) throws Exception{
        Result<List<String>> result=stockCountService.createStock(StockName,FirstPrice);
        List<String> stockData = result.getData();
        for (String data : stockData) {
            System.out.println(data); // 打印每一项数据
        }
        return result;
    }

}
